<?php
/***************************************************************
*  Copyright notice
*
*  (c) 2007 Christian Finkemeier <info@dpi-one.de>
*  All rights reserved
*
*  This script is part of the TYPO3 project. The TYPO3 project is
*  free software; you can redistribute it and/or modify
*  it under the terms of the GNU General Public License as published by
*  the Free Software Foundation; either version 2 of the License, or
*  (at your option) any later version.
*
*  The GNU General Public License can be found at
*  http://www.gnu.org/copyleft/gpl.html.
*
*  This script is distributed in the hope that it will be useful,
*  but WITHOUT ANY WARRANTY; without even the implied warranty of
*  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
*  GNU General Public License for more details.
*
*  This copyright notice MUST APPEAR in all copies of the script!
***************************************************************/
/**
 * [CLASS/FUNCTION INDEX of SCRIPT]
 *
 *
 *
 *   69: class mailform_userfunc extends tslib_pibase
 *
 *              SECTION: Main function
 *  112:     function insertData($str)
 *
 * TOTAL FUNCTIONS: 1
 *
 */






















require_once(PATH_tslib.'class.tslib_pibase.php');


/**
 * Plugin 'Frontend user System' for the 'user_system' extension.
 *
 * @author	Christian Finkemeier <info@dpi-one.de>
 * @package	TYPO3
 * @subpackage	user_system
 */
class tx_mailformuserfunc_pi extends tslib_pibase {
	var $prefixId = 'tx_mailformuserfunc_pi';		// Same as class name
	var $scriptRelPath = 'pi1/class.tx_mailformuserfunc_pi.php';	// Path to this script relative to the extension dir.
	var $extKey = 'mailform_userfunc';	// The extension key.























	/***************************
	 *
	 * Main function
	 *
	 **************************/

	
	
	/**
	 * Implements the "insertData" property of stdWrap meaning that if strings matching {...} is found in the input string they will be substituted with the return value from getData (datatype) which is passed the content of the curly braces.
	 * Example: If input string is "This is the page title: {page:title}" then the part, '{page:title}', will be substituted with the current pages title field value.
	 *
	 * @param	string		Input value
	 * @return	string		Processed input value
	 * @see tslib_cObj::insertData
	 */
	function insertData($str) {
		// Load extension configuration
		$confArr = unserialize($GLOBALS['TYPO3_CONF_VARS']['EXT']['extConf'][$this->extKey]);
		// It is required to substitute the splitChar itself and the splitChar with htmlspecialchars converted
		$confArr['splitCharArr'] = array(
			htmlspecialchars($confArr['splitChar']),
			$confArr['splitChar'],
		);
		// Disable the frontend cache, if set in the extension configuration
		if ($confArr['no_cache']) {
			$GLOBALS['TSFE']->set_no_cache();
		}
		// Find all data values surrounded by braces "{ }"
		preg_match_all('/\{[^\}]+\}/s', $str, $dataFields, PREG_SET_ORDER);
		for ($i = 0; $i < count($dataFields); $i++) {
			$dataFields[$i][1] = str_replace($confArr['splitCharArr'], '|', $dataFields[$i][0]);
			$str = str_replace($dataFields[$i][0], $dataFields[$i][1], $str);
		}
		return $str;
	}
}



if (defined('TYPO3_MODE') && $TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['ext/mailform_userfunc/pi/class.tx_mailformuserfunc_pi.php'])	{
	include_once($TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['ext/mailform_userfunc/pi/class.tx_mailformuserfunc_pi.php']);
}

?>
